//ES12: FinalizationRegistry
const finalRegistry = new FinalizationRegistry(() => {
  console.log("有对象被销毁");
})

let obj = {
  name: "yz"
}
// 弱引用
let info = new WeakRef(obj)

finalRegistry.register(obj, "obj")
console.log(info.deref().name);
// 不定时回收
obj = null
